Skip to content

add os.findsubdirheader#2637

Open
mercury233 wants to merge 1 commit intopremake:masterfrom
mercury233:patch-findsubdirheader
Open

add os.findsubdirheader#2637
mercury233 wants to merge 1 commit intopremake:masterfrom
mercury233:patch-findsubdirheader

Conversation

@mercury233
Copy link
Contributor

What does this PR do?

Add an API os.findsubdirheader which can support searching relative paths.
Some libraries, by default, install header files within folders. For example, the header files for libfreetype-dev are located in:

/usr/include/freetype2/freetype/*.h
/usr/include/freetype2/ft2build.h

Previously, if a program included the header with #include <ft2build.h>, you had to use:
os.findheader("freetype2/ft2build.h") .. "freetype2"
to locate it.

Now you can simply use:
os.findsubdirheader("ft2build.h", "freetype2")
to achieve the same result.

How does this PR change Premake's behavior?

New API, no change to the existing APIs.

Anything else we should know?

This PR replace and close #2469 .

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!

src/base/os.lua Outdated

function os.findsubdirheader(headerpath, additionalpaths)
-- headerpath: a partial header file path
-- additionalpaths: required; a string or table of subdirectory paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc style is more often the one from os.findlib than os.findheader


### Availability ###

Premake 5.0-beta9 or later.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more beta9 now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which version should it use here?

Copy link
Member

@nickclark2016 nickclark2016 Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.0 -- The next release will be 5.0 stable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because Premake’s version numbers look rather conservative, I assumed that versions accepting new features would not become stable releases.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have decided to just cut it as a stable release. We won't be breaking any more APIs past 5.0 (hopefully)


### Availability ###

Premake 5.0 or later.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly add a See Also section for os.findsubdirheader.

Copy link
Member

@nickclark2016 nickclark2016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @Jarod42's comments. Address those and I'll be happy to merge.

- `os.findsubdirheader`: better support for header files in subdirectory than `os.findheader`
- update comment & document of `os.findheader`
@mercury233 mercury233 force-pushed the patch-findsubdirheader branch from 85a7f9e to 94c1353 Compare March 13, 2026 00:56
@mercury233
Copy link
Contributor Author

The documents and comments have been updated. Please feel free to modify them, as English is not my native language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants